/**
  ******************************************************************************
  * @file           : gui_form.h
  * @brief          : This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */
#ifndef __FRM_FORM_H
#define __FRM_FORM_H

#include <stdint.h>
#include "irkey.h"

#define GUI_COMPONENT_CACHE_MAXLEN   64u
#define GUI_COMP_TEXT_MAXLEN         64u
#define GUI_PAGE_CACHE_MAXLEN        20u

/* 如果发现nowpage错误则跳转回主页 并退出当前函数 */
#define page_error_check(npg)    {if(npg >= MAX_PAGE){gui_form_exec(&gui_from_main, 0, 0); return;}}

typedef struct
{
	void (*mute)   (void);
	void (*power)  (void);
  void (*keyt)   (void);
  void (*set)    (void);
  void (*home)   (void);
  void (*menu)   (void);
  void (*keyret) (void);
  void (*enter)  (void);
	void (*down)   (void);
	void (*up)     (void);
	void (*left)   (void);
	void (*right)  (void);
	void (*ok)     (void);
	void (*volinc) (void);
	void (*voldec) (void);
	void (*key0)   (void);
	void (*key1)   (void);
	void (*key2)   (void);
	void (*key3)   (void);
	void (*key4)   (void);
	void (*key5)   (void);
	void (*key6)   (void);
	void (*key7)   (void);
	void (*key8)   (void);
	void (*key9)   (void);
}GUI_FormKeysStru;

typedef struct _GUI_FormStru
{
	void (*load)   (uint8_t, uint8_t);
	void (*update) (uint8_t);
  GUI_FormKeysStru const *keys;
  const uint32_t *refresh;
}GUI_FormStru;

extern const GUI_FormStru gui_from_main;
extern const GUI_FormStru gui_from_settmenu;
extern const GUI_FormStru gui_from_paradisp;
extern const GUI_FormStru gui_from_parainput;
extern const GUI_FormStru gui_from_calmessage;
extern const GUI_FormStru gui_from_calimenu;

extern const GUI_FormStru gui_from_calzeroready;
extern const GUI_FormStru gui_from_calzerorunning;
extern const GUI_FormStru gui_from_calzerorunend;

extern const GUI_FormStru gui_from_calgmready;
extern const GUI_FormStru gui_from_calgmrunning;
extern const GUI_FormStru gui_from_calgmrunend;

extern const GUI_FormStru gui_from_calswready;
extern const GUI_FormStru gui_from_calswrunning;
extern const GUI_FormStru gui_from_calswrunend;

extern const GUI_FormStru gui_from_state;
extern const GUI_FormStru gui_from_sensorinfo;

extern volatile GUI_FormStru const *gui_form_current;
extern void gui_form_exec(const GUI_FormStru *frm, uint8_t nowpage, uint8_t nowfocus);
extern void gui_form_common_home(void);
extern void gui_form_common_set(void);
extern void gui_form_common_enter(void);

extern uint32_t gui_mainmenu_refresh_time;
extern const uint32_t gui_maxdelay_refresh_time;

#endif /* __FRM_FORM_H */
